using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using DataAccess.Entities;

namespace DataAccess.Mapping
{
	public class UserMap : EntityTypeConfiguration<User>
	{
		public UserMap()
		{
			// Primary Key
			this.HasKey(t => t.Id);

			// Properties
			this.Property(t => t.Name)
				.IsRequired()
				.HasMaxLength(50);
				
			this.Property(t => t.Email)
				.IsRequired()
				.HasMaxLength(50);
				
			this.Property(t => t.LoginName)
				.IsRequired()
				.HasMaxLength(50);
				
			this.Property(t => t.Password)
				.IsRequired()
				.HasMaxLength(50);
				
			// Table & Column Mappings
			this.ToTable("User");
			this.Property(t => t.Id).HasColumnName("Id");
			this.Property(t => t.Name).HasColumnName("Name");
			this.Property(t => t.Email).HasColumnName("Email");
			this.Property(t => t.LoginName).HasColumnName("LoginName");
			this.Property(t => t.Password).HasColumnName("Password");
			this.Property(t => t.TotalMark).HasColumnName("TotalMark");
			this.Property(t => t.Role).HasColumnName("Role");
			this.Property(t => t.CreateDate).HasColumnName("CreateDate");
			this.Property(t => t.UpdateDate).HasColumnName("UpdateDate");
		}
	}
}

